<!-- 角色管理 -->

<template>
  <div>
    <!-- 列表 -->
    <el-card class="card">
      <ELTable v-bind="tableConfig">
        <template #btns="{ deleteAll }">
          <el-button type="primary" @click="add">
            <el-icon class="icon">
              <Plus />
            </el-icon>
            新增
          </el-button>

          <el-button :icon="Delete" type="danger" @click="deleteAll">批量删除</el-button>
        </template>

        <template #operate="{ scope, deleteHandle }">
          <el-button type="primary" :icon="Edit" text @click="uploadEdit(scope.row.id)">
            编辑
          </el-button>

          <el-button type="danger" :icon="Delete" text @click="deleteHandle(scope.row.id)">
            删除
          </el-button>
        </template>
      </ELTable>
    </el-card>
  </div>
</template>
<script setup lang="ts">
import { reactive, ref, onMounted } from "vue";
import { useRouter } from "vue-router";
import { delCompany, delMany, getCompanyList } from "@/api/system/Role/Role";
import ELTable, { TableData } from "@/components/ELTable.vue";
import { accountAddParams } from "@/api/system/Role/type";
import { Delete, Edit, Message, Document, Search, Refresh } from "@element-plus/icons-vue";
import router from "@/router";

const tableConfig = reactive<TableData>({
  loadData: getCompanyList,
  delete: delCompany,
  deleteAll: delMany,
  columns: [
    {
      prop: "id",
      label: "序号",
    },
    {
      prop: "name",
      label: "姓名",
    },
    {
      prop: "accountCounts",
      label: "关联账号数",
    },
    {
      prop: "addAccountName",
      label: "创建人",
    },
    {
      prop: "addTime",
      label: "创建时间",
    },

    {
      prop: "operate",
      label: "操作",
      slot: true,
    },
  ],
});

// 添加
const add = () => {
  router.push("/system/role-add");
};
// 编辑
const uploadEdit = (id: number) => {
  // console.log(id);
  router.push({ path: "/system/role-add", query: { id: id } });
};
</script>
<style scoped>
.card {
  margin: 10px;
}
</style>
